package exam.test2;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hzniufanglong
 * Date: 2020-06-20
 * Time: 11:29
 */
public class Covid19 {
	private String countryName;
	private int cases;

	public Covid19(String countryName, int cases) {
		this.countryName = countryName;
		this.cases = cases;
	}

	public String getCountryName() {
		return countryName;
	}

	public int getCases() {
		return cases;
	}

	public static void main(String[] args) {
		List<Covid19> list = new ArrayList<>();
		Scanner scanner = new Scanner(System.in);

		list.add(parseInputLine(scanner.nextLine()));
		list.add(parseInputLine(scanner.nextLine()));
		list.add(parseInputLine(scanner.nextLine()));

		Collections.sort(list, (o1, o2) -> Integer.compare(o1.getCases(), o2.getCases()));
		for (Covid19 covid19 : list) {
			System.out.println(covid19.getCountryName());
		}
	}

	private static Covid19 parseInputLine(String input) {
		String name = input.substring(0, input.lastIndexOf(" "));
		int cases = Integer.parseInt(input.substring(input.lastIndexOf(" ") + 1));
		return new Covid19(name, cases);
	}

}
